import {legacy_createStore as createStore, combineReducers, applyMiddleware } from 'redux'
import thunk from "redux-thunk";
import count from './modules/countInfo/reducer';
import global from './modules/global/reducer';
import userInfo from "./modules/userInfo/reducer";
import storage from "redux-persist/lib/storage";
import {persistReducer, persistStore} from "redux-persist";


const allReducer = combineReducers({
    countInfo: count,
    global: global,
    userInfo: userInfo
})

// redux 持久化配置
const persistConfig = {
    key: "redux-state",
    storage: storage
};

// 持久配置
const persistReducerConfig = persistReducer(persistConfig, allReducer);

// 创建 store
const store = createStore(persistReducerConfig, applyMiddleware(thunk));

// 创建持久化 store
const persistor = persistStore(store);

export {store, persistor};